<script lang="ts" setup>
import { ref } from 'vue'
import type { SettingProps } from '../props'
import SettingItem from './SettingItem.vue'

const props = withDefaults(defineProps<SettingProps>(), {
  settings: () => [],
})

const activeName = ref(props?.settings?.map(e => e?.name))
</script>

<template>
  <el-card class="w-full p-2">
    <el-collapse v-model="activeName">
      <el-collapse-item
        v-for="e in settings"
        :key="e.name"
        :title="e?.title"
        :name="e.name"
      >
        <template v-if="e?.items?.length">
          <SettingItem :settings="e?.items" />
        </template>
      </el-collapse-item>
    </el-collapse>
  </el-card>
</template>

<style lang="scss" module></style>
